
package rendi456.geom;

import java.awt.Point;
import java.awt.Rectangle;

public class Rect
{
	private final Rectangle rect;
	private int left;
	private int right;
	private int top;
	private int bottom;

	public  Rect()
	{
		this.rect = new Rectangle();
	}
	
	public void setBounds(int left, int right, int top, int bottom)
	{
		this.left = left;
		this.right = right;
		this.top = top;
		this.bottom = bottom;
	}
	
	public Rectangle getRectangle()
	{
		return new Rectangle(this.left, this.top, this.getWidth(), this.getHeight());
	}

	public int getWidth()
	{
		return this.bottom - this.top;
	}

	public int getHeight()
	{
		return this.right - this.left;
	}

	public void setLeft(int left)
	{
		this.left = left;
	}

	public void setRight(int right)
	{
		this.right = right;
	}

	public void setTop(int top)
	{
		this.top = top;
	}

	public void setBottom(int bottom)
	{
		this.bottom = bottom;
	}

	public int getLeft()
	{
		return this.left;
	}

	public int getRight()
	{
		return this.right;
	}

	public int getTop()
	{
		return this.top;
	}

	public int getBottom()
	{
		return this.bottom;
	}

	public int centerX()
	{
		return this.getWidth() / 2;
	}

	public int centerY()
	{
		return this.getHeight() / 2;
	}

	public Point getCenter()
	{
		return new Point(this.centerX(), this.centerY());
	}
	
	public boolean contains(Point p)
	{
		return this.left < p.x && this.right > p.x && this.top < p.y && this.bottom > p.y;
	}
}
